<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2018-05-16
  Time: 14:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/table/bootstrap-table.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/table/locale/bootstrap-table-zh-CN.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/date/Moment.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/statics/date/bootstrap-datetimepicker.min.js"></script>
    <!--mini ui-->
    <link href="${pageContext.request.contextPath}/statics/miniui/miniui.css" rel="stylesheet"
          type="text/css"/>
    <script src="${pageContext.request.contextPath}/statics/miniui/miniui.js"
            type="text/javascript"></script>


    <!--easyui-->
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/statics/easyui/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/easyui/icon.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/easyui/demo.css">

    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/easyui/jquery.easyui.min.js"></script>

    <!--调用static-->
    <link href="${pageContext.request.contextPath}/statics/css/jinhuo.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/KCPD.js"></script>

    <!--sweetalert模态框-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/statics/sweetalert/sweetalert.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/sweetalert/sweetalert.min.js"></script>


    <style type="text/css">
        body{
            /*font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;*/
        }
        #xiala1{
            width: 150px;
            display: inline-block;
            /*margin-top: 0px;*/
        }
        #xiala2{
            width: 150px;
            display: inline-block;
            /*margin-top: 0px;*/
        }
        #xiala3{
            width: 150px;
            display: inline-block;
            /*margin-top: 50px;*/
        }
        #waibian{
            padding: 50px;
        }
        #one{
            /*vertical-align: middle;*/
            height: 50px;
            display: inline-block;
            /*border-bottom: #e8e8e8 solid 1px;*/
            width:300px;
            vertical-align: middle;
        }
        #ren{
            vertical-align: middle;
            height: 50px;
            display: inline-block;
            width:100%;
        }
        #chaxun{
            margin-top:-18px;
            /*display: inline-block;*/
            /*height: 50px;*/
            /*width: 60px;*/
        }
        #rightfloat{
            display: inline-block;
            position: relative;
            /*right: -700px;*/
            /*top: -49px;*/
        }
        #shijian{
            height: 60px;
        }
        #t2div{
            height: 200px;
        }
        #t3div{
            height: 200px;
        }
        #date{
            margin-bottom: -20px;
            width: 500px;
            display: inline-block;
            height:50px;
        }
        #fontstyle{
            font-size: 16px;
        }
        button{
            z-index: 99;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $("#table").bootstrapTable({
                detailView:true,
                url: '${pageContext.request.contextPath}/KCGLPD/queryorder2',
                columns: [
                    {
                        field: 'order',
                        title: '盘点单号'
                    }, {
                        field: 'date',
                        title: '日期'
                    }, {
                        field: 'name',
                        title: '仓库名称'
                    }],onExpandRow:function (index,row,$detail) {
                    //产生一个表格
                    var  aa =$detail.html('<table></table>').find('table');
                    var id =row.id;
                    aa.bootstrapTable({
                        url:'${pageContext.request.contextPath}/KCGLPD/orderxiangxi?ordernumber='+row.order+'',
                        columns:[
                            {field:'number',title:'编号'},
                            {field:'name',title:'名称'},
                            {field:'companyid',title:'单位'},
                            {field:'spec',title:'规格型号'},
                            {field:'pi',title:'盘点数量'},
                            {field:'pis',title:'库存数量'},
                        ]
                    })
                },
            })
            $("#xiala3").change(function(){
                var opt = $("#jiu").bootstrapTable('getOptions');
                var cangku = $("#xiala3 option:selected").val()
                alert("值被改变"+cangku)

                $.post('${pageContext.request.contextPath}/KCGLPD/warequery', {
                    'cangku':cangku,
                    'pageSize': opt.pageSize,
                    'pageNumber': 1
                }, function (data) {

                    //重新给table绑定数据
                    $("#jiu").bootstrapTable("load", data);
                });
            });
            $.post("${pageContext.request.contextPath}/war/query",function (releset) {
                var e=releset;
                $('#xiala3').append('<option value=0 ></option>');
                $(e).each(function (i,e) {
                    $('#xiala3').append('<option value='+e.id+' >'+e.name+'</option>');
                })
                $('#xiala1').append('<option value=0 ></option>');
                $(e).each(function (i,e) {
                    $('#xiala1').append('<option value='+e.id+' >'+e.name+'</option>');
                })
            })
            $("#table2").bootstrapTable({
                url: '${pageContext.request.contextPath}/KCGLPD/queryorder',
                columns: [
                    {
                        field: 'order',
                        title: '盘点单号'
                    }, {
                        field: 'date',
                        title: '日期'
                    }, {
                        field: 'name',
                        title: '仓库名称'
                    }, {
                        field: 'count',
                        title: '商品条数'
                    }, {
                        field: 'sum',
                        title: '商品数量'
                    }, {
                        field: 'remark',
                        title: '备注'
                    }],
                onClickRow: function (row, $element, field) {
                    $("#table3").bootstrapTable({
                        <%--url: '${pageContext.request.contextPath}/KCGL/queryorder',{"":debugger},--%>
                        columns: [
                            {
                                field: 'number',
                                title: '商品编号'
                            }, {
                                field: 'name',
                                title: '商品名称'
                            }, {
                                field: 'companyid',
                                title: '单位'
                            }, {
                                field: 'spec',
                                title: '规格型号'
                            }, {
                                field: 'pis',
                                title: '库存数量'
                            }, {
                                field: 'pi',
                                title: '盘点数量'
                            }]
                    })
                    $.post('${pageContext.request.contextPath}/KCGLPD/orderxiangxi', {"ordernumber": row.order}, function (data) {
                        $("#table3").bootstrapTable("load", data)
                    })
                    $("#pdorder").text(row.order)
                }
            })

            var picker2 = $('#datetimepicker2').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            picker2.on('dp.change', function (e) {
                picker1.data('DateTimePicker').maxDate(e.date);
            });
            var picker3 = $('#datetimepicker3').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn'),
                //minDate: '2016-7-1'
            });
            var picker4 = $('#datetimepicker4').datetimepicker({
                format: 'YYYY-MM-DD',
                locale: moment.locale('zh-cn')
            });
            //动态设置最小值
            picker1.on('dp.change', function (e) {
                picker2.data('DateTimePicker').minDate(e.date);
            });
            //动态设置最大值
            picker2.on('dp.change', function (e) {
                picker1.data('DateTimePicker').maxDate(e.date);
            });
        });
        function shenhe(){
            $('#shenhe').modal("show");
            $("#lin2").bootstrapTable({
                url: '${pageContext.request.contextPath}/KCGLPD/queryorder',
                singleSelect : true,
                columns: [
                    { checkbox: true},
                    {
                        field: 'order',
                        title: '盘点单号'
                    }, {
                        field: 'date',
                        title: '日期'
                    }, {
                        field: 'name',
                        title: '仓库名称'
                    }, {
                        field: 'admin',
                        title: '操作员'
                    }, {
                        field: 'count',
                        title: '商品条数'
                    }, {
                        field: 'sum',
                        title: '商品数量'
                    }],
            })
        }

        function xiayibu(){
            var arr = $("#lin2").bootstrapTable('getAllSelections');
            if(arr.length<=0){
                swal("请选择要盘点的单号")
            }else{
                $('#shenhe').modal("hide");
                $('#xiuzheng').modal("show");
                $("#lin3").bootstrapTable({
                    <%--url: '${pageContext.request.contextPath}/KCGL/queryorder',{"":debugger},--%>
                    columns: [
                        {
                            field: 'number',
                            title: '商品编号'
                        }, {
                            field: 'name',
                            title: '商品名称'
                        }, {
                            field: 'companyid',
                            title: '单位'
                        }, {
                            field: 'spec',
                            title: '规格型号'
                        }, {
                            field: 'pis',
                            title: '库存数量'
                        }, {
                            field: 'pi',
                            title: '盘点数量'
                        }, {
                            field: 'ordernumber',
                            title: '盘点单号',
                            visible : false
                        }]
                })
                $.post('${pageContext.request.contextPath}/KCGLPD/orderxiangxi', {"ordernumber": arr[0].order}, function (data) {
                    $("#lin3").bootstrapTable("load", data)
                })
                // $("#pdorder").text(row.order)
            }
            // alert(arr[0].order)

        }
        function xiuzheng(){
            $('#shenhe').modal("show");
            $('#xiuzheng').modal("hide");
        }
        function gaikucun(){
            var arr = $("#lin3").bootstrapTable('getData');
            var arr2 = $("#lin2").bootstrapTable('getAllSelections');
            var bianhao = new Array()
            var cangku = 0;
            var shuliang = new Array()
            var order = arr[0].ordernumber
            if(arr2[0].name=="酒库"){
                cangku = 1;
            }else if(arr2[0].name=="主仓库"){
                cangku = 2;
            }


            $.each(arr,function (i,e) {
                bianhao[i] = arr[i].name;
                shuliang[i] = arr[i].pi;
            })
            alert("编号："+bianhao[0]+"仓库："+cangku+"数量："+shuliang[0]+"单号"+order)
            $.post("${pageContext.request.contextPath}/KCGLPD/xiuzheng",{"bianhao":JSON.stringify(bianhao),"shuliang":JSON.stringify(shuliang),"cangku":cangku,"order":order},function (data) {
                $("#table2").bootstrapTable("load",data)
            });
            $("#xiuzheng").modal("hide");
        }
        function chaxun(){
            var start = $("#start").val();
            var end = $("#end").val();
            var cangku = $("#xiala1 option:selected").text()
            $.post("${pageContext.request.contextPath}/KCGLPD/querytiaojian",{"start":start,"end":end,"cangku":cangku},function (data) {
                $("#table").bootstrapTable("load",data)
            });
        }
        $('#myTabs a').click(function (e) {
            e.preventDefault()
            $(this).tab('show')
        })
        $('#myTabs a[href="#profile"]').tab('show')  // Select tab by name
        $('#myTabs a:first').tab('show') // Select first tab
        $('#myTabs a:last').tab('show') // Select last tab
        $('#myTabs li:eq(2) a').tab('show') // Select third tab (0-indexed)
        function tan(){
            $.post('${pageContext.request.contextPath}/KCGLPD/suiji', function (data) {
                $("#order").text(data)
            })
            $("#myModal").modal("show");
        }

    </script>

</head>
<body>
<div id="zuida">
    <!-- Nav tabs -->
    <h1 style="text-align: center">库存盘点</h1>
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">盘点列表</a></li>
        <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">历史盘点查询</a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content" id="waibian">
        <div role="tabpanel" class="tab-pane active" id="home">
            <div id="shijian">
                <div class="row"  style="position:absolute;width: 700px;display: inline-block;line-height: 35px">
                    <div id="rightfloat">
                        &emsp;
                        <button onclick="tan()" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
                            新增盘点单
                        </button>&emsp;
                        <button onclick="shan()" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
                            删除盘点单
                        </button>&emsp;
                        <button onclick="shenhe()" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">
                            盘点审核
                        </button>
                    </div>
                </div>
            </div>
            <div class="table-responsive" id="t2div">
                <table class="table" id="table2">

                </table>
            </div>
            <div>
                <p><span style="color: darkred;">盘点商品明细</span>&emsp;盘点单号:<span id="pdorder"></span>&emsp;&emsp;</p>

            </div>
            <div class="table-responsive" id="t3div">
                <table class="table" id="table3">

                </table>
            </div>
        </div>
        <div role="tabpanel" class="tab-pane" id="profile">
        <div id="one">
                <span>仓库名称：</span>
            <select class="form-control" id="xiala1">

            </select>
        </div>
        <div class="row" id="date">
            <div class='col-sm-6'>
                <div class="form-group">
                    <!--指定 date标记-->
                    <div class='input-group date' id='datetimepicker3'>
                        <input type='text' class="form-control" placeholder="选择开始时间" id="start"/>
                        <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
                </span>
                    </div>
                </div>
            </div>
            <div class='col-sm-6'>
                <div class="form-group">
                    <!--指定 date标记-->
                    <div class='input-group date' id='datetimepicker4'>
                        <input type='text' class="form-control" placeholder="选择结束时间" id="end"/>
                        <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
                </span>
                    </div>
                </div>
            </div>
        </div>
            &emsp;&emsp;
        <button onclick="chaxun()" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off" id="chaxun">
            查询
        </button>
        <div class="table-responsive">
            <table class="table" id="table">

            </table>
        </div>
    </div>
    </div>
</div>




<!--老货物添加-->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 1200px;" class="modal-dialog" role="document">
        <div   class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">新增货品</h4>
            </div>
            <div style="height:750px" class="modal-body">
                <div id="fontstyle">
                    <div>
                        <div>
                            盘点单号:<span id="order">${order}</span>&emsp;&emsp;盘点仓库：
                            <select class="form-control" id="xiala3">

                            </select>&emsp;&emsp;盘点日期：
                            <div class="row" style="width: 200px;display: inline-block;line-height: 35px;margin-left: 250px;margin-bottom: -10px;">
                                <div class='col-sm-6'>
                                    <div class="form-group" style="margin: 0px;margin-bottom: -11px;">
                                        <!--指定 date标记-->
                                        <div class='input-group date' id='datetimepicker2' style="">
                                            <input id="pddate" type='text' class="form-control" style="width: 300px;"/>
                                            <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                                        </div>
                                    </div>
                                </div>
                            </div>&emsp;&emsp;操作员：admin
                        </div>
                    </div>
                    <div>备注：<input type="text" id="beizhu" class="form-control" placeholder="备注" style="width: 500px;display: inline-block;margin-top:10px;margin-bottom:10px;"></div>
                </div>
                <div style="width: 575px;background-color: #94b7e7;height:  600px; display: inline-block;" class="zuo1">

                    <div class="easyui-tabs" style="width:100%;height:600px;display: inline-block" >

                        <div title="About" style="padding:10px;display: inline-block">

                            <form class="form-inline">
                                <div class="form-group">
                                    <input id="name" type="text" class="form-control" placeholder="搜索内容">
                                </div>
                                <div class="form-group">
                                    <input id="lei" class="easyui-combogrid" style="width:200px" data-options="
                                                panelWidth: 300,
                                                idField: 'id',
                                                textField: 'name',
                                                url: '${pageContext.request.contextPath}/commtype/list',
                                                method: 'get',
                                                columns: [[
                                                    {field:'id',title:'类别id',width:100},
                                                    {field:'name',title:'分类名称',width:150},
                                                ]],
                                                fitColumns: true
                                            ">
                                </div>
                                <button onclick="search()" type="button" class="btn btn-default">查询</button>
                            </form>

                            <table id="jiu"></table>
                        </div>

                    </div>
                </div>
                <div style="margin-top:90px;margin-left:5px ;width: 575px;background-color: #FFFFFF;height: 500px; display: inline-block" class="you1">
                    <table id="lin1"></table>
                </div>
            </div>
            <div class="modal-footer" style="z-index:999">
                <button type="button" class="btn btn-default" data-dismiss="modal">退出</button>
                <button type="button" onclick="ll()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>

<!--双击添加-->
<!-- Modal -->
<input type="hidden" id="lei1">
<input type="hidden" id="yan1">
<input type="hidden" id="dan1">

<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 500px;" class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel2">货品信息（商品入库）</h4>
            </div>
            <div style="height: 200px;" class="modal-body">
                <!--上部-->
                <div style="width: 100%;height: 140px;" id="shang">

                    <div style="display:inline-block; width:228px;" class="jdzuo">
                        <ul>
                            <li style="font-size: 18px;list-style:none;">货品编号:&emsp;<span id="bianhao">1</span></li>
                            <input type="hidden" name="guige" id="guige">
                            <li style="font-size: 18px;list-style:none;">当前库存:&emsp;<span id="kucun">4</span></li>
                        </ul>
                    </div>
                    <div style="margin-left:0px;display:inline-block; width:230px;" class="jdyou">
                        <ul>
                            <li style="font-size: 18px;list-style:none;">货品名称:&emsp;<span id="hpname">1</span></li>
                            <input type="hidden" name="danwei" id="danwei">
                            <input type="hidden" name="danhao" id="danhao">
                            <li style="font-size: 18px;list-style:none;">盘点库存:&emsp;<input class="form-control" type="text" name="pdkucun" id="pdkucun" style="width: 50px;display: inline-block"> </li>
                        </ul>
                    </div>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" id="ddd" onclick="ti1()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 500px;" class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel3">货品信息（商品入库）</h4>
            </div>
            <div style="height: 200px;" class="modal-body">
                <!--上部-->
                <div style="width: 100%;height: 140px;" id="shang3">

                    <div style="display:inline-block; width:228px;" class="jdzuo">
                        <ul>
                            <li style="font-size: 18px;list-style:none;">货品编号:&emsp;<span id="bianhao3">1</span></li>
                            <input type="hidden" name="guige" id="guige3">
                            <li style="font-size: 18px;list-style:none;">当前库存:&emsp;<span id="kucun3">4</span></li>
                        </ul>
                    </div>
                    <div style="margin-left:0px;display:inline-block; width:230px;" class="jdyou">
                        <ul>
                            <li style="font-size: 18px;list-style:none;">货品名称:&emsp;<span id="hpname3">1</span></li>
                            <input type="hidden" name="danwei" id="danwei3">
                            <input type="hidden" name="danhao" id="danhao3">
                            <li style="font-size: 18px;list-style:none;">盘点库存:&emsp;<input class="form-control" type="text" name="pdkucun" id="pdkucun3" style="width: 50px;display: inline-block"> </li>
                        </ul>
                    </div>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" id="ddd3" onclick="tixiu()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="shenhe" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 1200px;" class="modal-dialog" role="document">
        <div   class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabe4">盘点审核</h4>
            </div>
            <div style="height:420px" class="modal-body">
                    <table id="lin2"></table>
            </div>
            <div class="modal-footer" style="z-index:999">
                <button type="button" class="btn btn-default" data-dismiss="modal">退出</button>
                <button type="button" onclick="xiayibu()" class="btn btn-primary">下一步</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="xiuzheng" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div style="width: 1200px;" class="modal-dialog" role="document">
        <div   class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabe5">盘点审核</h4>
            </div>
            <div style="height:420px" class="modal-body">
                <table id="lin3"></table>
            </div>
            <div class="modal-footer" style="z-index:999">
                <button type="button" onclick="xiuzheng()" class="btn btn-primary">上一步</button>
                <button type="button" onclick="gaikucun()" class="btn btn-primary">修正库存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">退出</button>

            </div>
        </div>
    </div>
</div>
</body>
</html>
